package com.kkb.kkbportal.controller;


import com.github.pagehelper.PageInfo;
import com.kkb.kkbcommon.api.CommonResult;
import com.kkb.kkbportal.domain.AddGroup;
import com.kkb.kkbportal.domain.Carousel;
import com.kkb.kkbportal.domain.UpdateGroup;
import com.kkb.kkbportal.service.CarouselService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 杜垣均
 * @title: Carousel
 * @projectName kkb-parent-v2
 * @description 轮播图后台管理
 * @data 15:10 2021/8/19
 */
@Api(tags = "首页轮播图管理")
@RestController
@RequestMapping("/home/carousel")
public class CarouselController {

    @Autowired
    private CarouselService carouselService;

    @ApiOperation("轮播图列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "carousel", value = "轮播图筛选条件", dataType = "Carousel"),
            @ApiImplicitParam(name = "pageNum", value = "当前页数", defaultValue = "1", dataType = "int"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示数量", defaultValue = "10", dataType = "int")
    })
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public CommonResult<List<Carousel>> carouselList(Carousel carousel,
                                                     @RequestParam(defaultValue = "1") Integer pageNum,
                                                     @RequestParam(defaultValue = "10") Integer pageSize) {
        PageInfo<Carousel> page = carouselService.selectCarouselList(carousel, pageNum, pageSize);
        return CommonResult.success(page.getList(), "查询成功");
    }
}

